import { Typography } from 'antd'
import React from 'react'
import { QuestionParagraphDefaultProps, QuestionParagraphPropsType } from './interface'

const Component: React.FC<QuestionParagraphPropsType> = props => {
  const { text = '', isCenter } = { ...QuestionParagraphDefaultProps, ...props }

  const textList = text.split('\n')
  return (
    <Typography style={{ textAlign: isCenter ? 'center' : 'start', marginBottom: 0 }}>
      {textList.map((t, index) => {
        return (
          <span key={index}>
            {index > 0 && <br />}
            {t}
          </span>
        )
      })}
    </Typography>
  )
}

export default Component
